package com.pzhu.user.dao;

import com.mybatisflex.core.query.QueryCondition;
import com.mybatisflex.core.query.QueryWrapper;
import com.pzhu.base.common.utils.mybatisflex.BaseService;
import com.pzhu.base.common.utils.mybatisflex.QueryUtils;
import com.pzhu.user.domain.entity.RolePermission;
import org.apache.commons.collections4.CollectionUtils;

import java.util.Collections;
import java.util.List;

import static com.pzhu.user.domain.entity.table.RolePermissionTableDef.ROLE_PERMISSION;

/**
 * @author 75073
 * @description 针对表【role_permission(角色权限关系)】的数据库操作Mapper
 * @createDate 2024-02-19 00:37:22
 */
public interface RolePermissionDAO extends BaseService<RolePermission> {

    default List<RolePermission> listByRoleIds(List<Long> roleIdList){
        if (CollectionUtils.isEmpty(roleIdList)){
            return Collections.emptyList();
        }
        QueryWrapper queryWrapper = new QueryWrapper();
        QueryCondition condition = QueryUtils.and(ROLE_PERMISSION.ROLE_ID.in(roleIdList));
        queryWrapper.where(condition);
        return selectListByQuery(queryWrapper);
    }
}
